﻿package com.wandian.view.components.ui
{
	import com.wandian.data.GameData;

	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	import flash.system.Capabilities;

	/**
	 * 声音管理
	 * @author long
	 */
	public class SoundManage extends Object
	{
		public static var isPlay:Boolean=true;
		private static var _soundTransform:SoundTransform=new SoundTransform();
		private static var nVolume:Number=0.8;
		private static var _secondTen:Sound;
		private static var _secondChannel:SoundChannel=new SoundChannel();
		private static var _second1Channel:SoundChannel=new SoundChannel();
		private static var _global:GameData=GameData.getInstance();

		public function SoundManage()
		{
			return;
		}

		public static function set volume(param1:Number):void
		{
			nVolume=param1;
			_soundTransform.volume=nVolume;
			return;
		}

		public static function get volume():Number
		{
			return nVolume;
		}

		public static function playSound(str:String, sex:int=0, initSex:int=0):void
		{
			var getMathRadom:*=function(param1:int, param2:int):int
			{
				return Math.floor(Math.random() * param2 + param1);
			};
			var getSound:*=function(param1:String):void
			{
				var _loc_2:*=GameData.getClass(param1);
				if (_loc_2 == null)
				{
					return;
				}
				var _loc_3:*=new _loc_2;
				_second1Channel=_loc_3.play();
				_second1Channel.soundTransform=_soundTransform;
				return;
			};
			var getTimeTipSound:*=function(param1:String, param2:Boolean=true):void
			{
				var ClassSound:Class;
				var strSound:*=param1;
				var play:*=param2;
				return;
			};
			if (isPlay == false)
			{
				return;
			}
			try
			{
				if (!Capabilities.hasEmbeddedVideo)
				{
					return;
				}
				if (_global.userInfo.userVo.gp == GameData.QQSGAME_SID)
				{
					if (str == "AllIn")
					{
						return;
					}
				}

			}
			catch (evt:Error)
			{
				return;
			}
			switch (str)
			{
				case "Deal":
				case "Card":
				case "ShowCard":
				case "SitDown":
				case "StandUp":
				case "CallChip1":
				case "CallChip2":
				case "CallChip3":
				case "CallChip4":
				case "MoveChip":
				case "Tip":
				case "middle":
				case "EarnMoney":
				case "TimeOver":
				case "Win":
				case "CardFlip":
				{
					getSound(str);
					break;
				}
				case "PlayerSecondTen":
				{
					getTimeTipSound("SecondTen", true);
					break;
				}
				case "StopSecondTen":
				{
					getTimeTipSound("SecondTen", false);
					break;
				}
				case "Call":
				{
					if (sex == 0)
					{
						if (initSex == 1)
						{
							getSound("G" + str + getMathRadom(1, 2));
						}
						else
						{
							getSound("M" + str + getMathRadom(1, 2));
						}
					}
					else if (sex == 1)
					{
						getSound("G" + str + getMathRadom(1, 2));
					}
					else
					{
						getSound("M" + str + getMathRadom(1, 2));
					}
					break;
				}
				case "Check":
				{
					if (sex == 0)
					{
						if (initSex == 1)
						{
							getSound("G" + str + getMathRadom(1, 4));
						}
						else
						{
							getSound("M" + str + getMathRadom(1, 4));
						}
					}
					else if (sex == 1)
					{
						getSound("G" + str + getMathRadom(1, 4));
					}
					else
					{
						getSound("M" + str + getMathRadom(1, 4));
					}
					break;
				}
				case "Fold":
				{
					if (sex == 0)
					{
						if (initSex == 1)
						{
							getSound("G" + str + getMathRadom(1, 4));
						}
						else
						{
							getSound("M" + str + getMathRadom(1, 3));
						}
					}
					else if (sex == 1)
					{
						getSound("G" + str + getMathRadom(1, 4));
					}
					else
					{
						getSound("M" + str + getMathRadom(1, 3));
					}
					break;
				}
				case "Raise":
				{
					if (sex == 0)
					{
						if (initSex == 1)
						{
							getSound("G" + str + getMathRadom(1, 4));
						}
						else
						{
							getSound("M" + str + getMathRadom(1, 4));
						}
					}
					else if (sex == 1)
					{
						getSound("G" + str + getMathRadom(1, 4));
					}
					else
					{
						getSound("M" + str + getMathRadom(1, 4));
					}
					break;
				}
				case "AllIn":
				{
					if (sex == 0)
					{
						if (initSex == 1)
						{
							getSound("G" + str + getMathRadom(1, 4));
						}
						else
						{
							getSound("M" + str + getMathRadom(1, 4));
						}
					}
					else if (sex == 1)
					{
						getSound("G" + str + getMathRadom(1, 4));
					}
					else
					{
						getSound("M" + str + getMathRadom(1, 4));
					}
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

	}
}
